import { defineAsyncComponent } from 'vue'
export { confirm } from './confirm'
export { message } from './message'
export default {
  install(app) {
    // glob: 可以在文件系统中导入多个模块
    const components = import.meta.glob('./*/index.vue')
    for (let [fullPath, fn] of Object.entries(components)) {
      const componentName = 'm-' + fullPath.replace('./', '').split('/')[0]
      // defineAsyncComponent: 创建一个按需加载的异步组件
      app.component(componentName, defineAsyncComponent(fn))
    }
  }
}
